﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DataFileApplication_WPF.Extensions;
using System.Windows.Controls;
using System.Windows;

namespace DataFileApplication_WPF.Common
{
    public class ValueTemplateSelector : DataTemplateSelector
    {
        public DataTemplate IntTemplate { get; set; }
        public DataTemplate FloatTemplate { get; set; }
        public DataTemplate DoubleTemplate { get; set; }
        public DataTemplate BoolTemplate { get; set; }
        public DataTemplate TextTemplate { get; set; }

        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
            if (string.IsNullOrEmpty(item.ToString()))
            {
                return base.SelectTemplate(item, container);
            }

            var val = Enum.Parse(typeof(EnumDataType), item.ToString());
            switch (val)
            {
                case EnumDataType.Integer:
                    return IntTemplate;
                //case EnumDataType.Float:
                //    return FloatTemplate;
                case EnumDataType.Double:
                    return DoubleTemplate;
                case EnumDataType.String:
                    return TextTemplate;
                case EnumDataType.Boolean:
                    return BoolTemplate;
            }
            //}
            return base.SelectTemplate(item, container);
        }
    }
}
